package cn.zhaozhiqi.remote.fallback;

import cn.zhaozhiqi.remote.api.IRuleFeignClient;
import cn.zhaozhiqi.remote.dto.*;
import cn.zhaozhiqi.result.JSONResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RuleFeignClientFallbackFactory implements FallbackFactory<IRuleFeignClient> {
    @Override
    public IRuleFeignClient create(Throwable cause) {
        return new IRuleFeignClient() {
            @Override
            public JSONResult<ExpectsOrderDto> orderComputed(RuleComputedDto dto) {
                return JSONResult.error("获取订单规则异常");
            }

            @Override
            public JSONResult<WaitTimeDetailDto> waitTimeConputed(WaitTimeComputedDto dto) {
                return JSONResult.error("获取等时费计算规则异常");
            }

            @Override
            public JSONResult<OrderProfitsharingResultDto> getOrderProfitsharingDto(OrderProfitsharingDto dto) {
                return JSONResult.error("获取今日分账规则异常");
            }
        };
    }
}
